
/*import java.io.*;

import lejos.nxt.*;
import lejos.nxt.comm.*;
import lejos.robotics.navigation.*; 


public class BTReceive {
	boolean desplaz; 
	static DifferentialPilot pilot = new DifferentialPilot(4f, 13f, Motor.A, Motor.C); 
  public static void main(String [] args) throws Exception {
    String connected = "Conectado";
    String waiting = "Esperando...";
    String closing = "Cerrando...";
    Boolean enviar= false;
    BTReceive esclavo = new  BTReceive();
	 LCD.drawString("'Esclavo'", 0, 1);
	 Button.waitForAnyPress();
	 LCD.drawString("'PRESIONE ENTER'", 0, 3);
	 Button.ENTER.waitForPress();
	 
	 
      LCD.drawString(waiting,0,0);
      NXTConnection connection = Bluetooth.waitForConnection(); 
      LCD.clear();
      LCD.drawString(connected,0,0);

      DataInputStream dis = connection.openDataInputStream();
      DataOutputStream dos = connection.openDataOutputStream();

      boolean s = dis.readBoolean();      
      
      
      
      if (s=true){
    	  LCD.drawString("recibido", 1, 4);
    	  
          for(int i =0; i<1; i++){    	  
          pilot.travel(50);
          pilot.rotate(90);
          pilot.travel(30);
          enviar=true;
          }
          dos.writeChars("k");
          dos.flush();
      }
      else {
    	  LCD.drawString("no se recibio", 1, 4);
      }
      
      dis.close();
      dos.close();

      LCD.clear();
      LCD.drawString(closing,0,0);

      connection.close();
      LCD.clear();
    }
  
}*/
import java.io.*;

import lejos.nxt.*;
import lejos.nxt.comm.*;
import lejos.robotics.navigation.*; 

public class BTReceive {
	static DifferentialPilot pilot = new DifferentialPilot(4f, 13.4f, Motor.A, Motor.C); 
	
  public static void main(String [] args) throws Exception {
    String connected = "Conectado";
    String waiting = "Esperando...";
    String closing = "Cerrando...";
   int contador=0;
    	
   while (!Button.ESCAPE.isPressed()){
    	
      LCD.drawString(waiting,0,0);
      NXTConnection connection = Bluetooth.waitForConnection(); 
      LCD.clear();
      LCD.drawString(connected,0,0);

      DataInputStream dis = connection.openDataInputStream();
      DataOutputStream dos = connection.openDataOutputStream();

      boolean s = dis.readBoolean();        
            
      if (s=true){
    	  LCD.drawString("recibido", 1, 4);
    	  
          for(int i =0; i<1; i++){    	  
          pilot.travel(50);
          pilot.rotate(90);
          pilot.travel(30);
          
          }
          dos.writeChars("k");
          dos.flush();
      }
      else {
    	  LCD.drawString("no se recibio", 1, 4);
      }
      
      dis.close();
      dos.close();

      LCD.clear();
      LCD.drawString(closing,0,0);

      connection.close();
      LCD.clear();
      
  
      }
    Button.waitForAnyPress();
    }
    
     
  }
